﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Detail
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <h2>Detail</h2>
    <div id="product_detail">
    <div id="product_left">
        <%
            string image = Model.Image;
            if (image == null)
                image = "/Content/images/default_image.jpg";
            else
                image = "../../" + image;
        %>
        <img src="<%=image %>" width="300" height="200" alt="" title="" />
    </div>
    <div id="product_right">
        <h4>  <%= Html.Encode(Model.Name) %></h4>
        <div id="manufacturer"><bold>Developed by:</bold><%=Model.Manufacturer %></div>
        <div id="display_price"> $<%= Html.Encode(Model.Price) %></div>
        <div class="quatity">Quatity: <input type="text" value="1" name="quatity" id="quatity<%=Model.Id %>" /></div>
         <div>
                <button onclick="javascript:addtocart(<%=Model.Id %>, 1, '<%=Model.Name %>',1, <%=Model.Price %>)" class="button btn-cart" title="Add to Cart" type="button"><span>Add to Cart</span></button>          
         </div>
        <div id="display_description"><%= Html.Encode(Model.Description) %></div>
        
    </div>

    </div>
     <script type="text/javascript">
         function addtocart(id, type, name, quatity, price) {
             var div = "quatity" + id;
             var qua = parseInt(document.getElementById(div).value);
             if (isNaN(qua)) {
                 alert("Please enter a number");
                 document.getElementById(div).value = "1";
                 return false;
             }
             var Product = new Array();
             Product[0] = id;                         //id
             Product[1] = type;                         //type
             Product[2] = name;              //name
             Product[3] = qua;                         //quatity
             Product[4] = price;                       //price
             Product[5] = Product[3] * Product[4];   //total

             list.add(Product);
         }
         </script>
</asp:Content>
